/// 设备项模型
class DeviceItem {
  final String id;
  final String name;
  final String type;
  final String status; // online, offline
  final int iconData;
  final bool isOn;
  
  DeviceItem({
    required this.id,
    required this.name,
    required this.type,
    required this.status,
    required this.iconData,
    required this.isOn,
  });
  
  /// 创建一个新的DeviceItem实例，但保留部分属性
  DeviceItem copyWith({
    String? id,
    String? name,
    String? type,
    String? status,
    int? iconData,
    bool? isOn,
  }) {
    return DeviceItem(
      id: id ?? this.id,
      name: name ?? this.name,
      type: type ?? this.type,
      status: status ?? this.status,
      iconData: iconData ?? this.iconData,
      isOn: isOn ?? this.isOn,
    );
  }
  
  /// 从JSON映射创建DeviceItem
  factory DeviceItem.fromJson(Map<String, dynamic> json) {
    return DeviceItem(
      id: json['id'],
      name: json['name'],
      type: json['type'],
      status: json['status'],
      iconData: json['iconData'],
      isOn: json['isOn'],
    );
  }
  
  /// 转换为JSON映射
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'type': type,
      'status': status,
      'iconData': iconData,
      'isOn': isOn,
    };
  }
} 